import { createRouter, createWebHistory } from 'vue-router';
import { useDark, useToggle } from '@vueuse/core';
const isDark = useDark();
const toggleDark = useToggle(isDark);

const routes = [
  {
    path: '/',
    redirect: '/shares'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/shares/:id/post/:code',
    name: 'shares',
    component: () => import('@/views/sharePage/index.vue')
  },
  {
    path: '/share/:id/post/:isSmall',
    name: 'share',
    component: () => import('@/views/share/index.vue')
  }
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
});

// 刷新用户信息

// 导航守卫
router.beforeEach(async (to, from) => {});

router.afterEach(() => {
  // 跳转成功置顶
  window.scrollTo(0, 0);
});

export default router;
